﻿namespace SS.WPF.Framework.Restriction
{
    using System.Text.RegularExpressions;

    public class RegexRestriction : Restriction<string>
    {
        private string _regexPattern;

        public string RegexPattern
        {
            get
            {
                return this._regexPattern;
            }
            set
            {
                this._regexPattern = value;

            }
        }

        public override bool Validate(string value)
        {
            return Regex.IsMatch(value, this._regexPattern);
        }

        public override string Description
        {
            get
            {
                return string.Format("{0}", this.RegexPattern.TrimEnd('$').TrimStart('^'));
            }
        }

        public override bool CanParse(string text)
        {
            return true;
        }
    }
}